home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / SMB_FS.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  7KB  |  225 lines

  1. /*
  2.  *  smb_fs.h
  3.  *
  4.  *  Copyright (C) 1995 by Paal-Kr. Engstad and Volker Lendecke
  5.  *  Copyright (C) 1997 by Volker Lendecke
  6.  *
  7.  */
  8.  
  9. #ifndef _LINUX_SMB_FS_H
  10. #define _LINUX_SMB_FS_H
  11.  
  12. #include <linux/smb.h>
  13.  
  14. /*
  15.  * ioctl commands
  16.  */
  17. #define    SMB_IOC_GETMOUNTUID        _IOR('u', 1, __kernel_uid_t)
  18. #define SMB_IOC_NEWCONN                 _IOW('u', 2, struct smb_conn_opt)
  19.  
  20. #ifdef __KERNEL__
  21.  
  22. #include <asm/unaligned.h>
  23.  
  24. #define WVAL(buf,pos) \
  25. (le16_to_cpu(get_unaligned((__u16 *)((__u8 *)(buf) + (pos)))))
  26. #define DVAL(buf,pos) \
  27. (le32_to_cpu(get_unaligned((__u32 *)((__u8 *)(buf) + (pos)))))
  28. #define WSET(buf,pos,val) \
  29. put_unaligned(cpu_to_le16((__u16)(val)), (__u16 *)((__u8 *)(buf) + (pos)))
  30. #define DSET(buf,pos,val) \
  31. put_unaligned(cpu_to_le32((__u32)(val)), (__u32 *)((__u8 *)(buf) + (pos)))
  32.  
  33. /* where to find the base of the SMB packet proper */
  34. #define smb_base(buf) ((__u8 *)(((__u8 *)(buf))+4))
  35.  
  36. #include <linux/vmalloc.h>
  37.  
  38. #ifdef DEBUG_SMB_MALLOC
  39.  
  40. extern int smb_malloced;
  41. extern int smb_current_vmalloced;
  42.  
  43. static inline void *
  44. smb_vmalloc(unsigned int size)
  45. {
  46.         smb_malloced += 1;
  47.         smb_current_vmalloced += 1;
  48.         return vmalloc(size);
  49. }
  50.  
  51. static inline void
  52. smb_vfree(void *obj)
  53. {
  54.         smb_current_vmalloced -= 1;
  55.         vfree(obj);
  56. }
  57.  
  58. #else /* DEBUG_SMB_MALLOC */
  59.  
  60. #define smb_kmalloc(s,p) kmalloc(s,p)
  61. #define smb_kfree_s(o,s) kfree_s(o,s)
  62. #define smb_vmalloc(s)   vmalloc(s)
  63. #define smb_vfree(o)     vfree(o)
  64.  
  65. #endif /* DEBUG_SMB_MALLOC */
  66.  
  67. /*
  68.  * Flags for the in-memory inode
  69.  */
  70. #define SMB_F_CACHEVALID    0x01    /* directory cache valid */
  71. #define SMB_F_LOCALWRITE    0x02    /* file modified locally */
  72.  
  73. /*
  74.  * Bug fix flags
  75.  */
  76. #define SMB_FIX_WIN95    0x0001    /* Win 95 server */
  77. #define SMB_FIX_OLDATTR    0x0002    /* Use core getattr (Win 95 speedup) */
  78. #define SMB_FIX_DIRATTR    0x0004    /* Use find_first for getattr */
  79.  
  80. /* linux/fs/smbfs/mmap.c */
  81. int smb_mmap(struct file *, struct vm_area_struct *);
  82.  
  83. /* linux/fs/smbfs/file.c */
  84. extern struct inode_operations smb_file_inode_operations;
  85.  
  86. /* linux/fs/smbfs/dir.c */
  87. extern struct inode_operations smb_dir_inode_operations;
  88. void smb_renew_times(struct dentry *);
  89.  
  90. /* linux/fs/smbfs/ioctl.c */
  91. int smb_ioctl (struct inode *, struct file *, unsigned int, unsigned long);
  92.  
  93. /* linux/fs/smbfs/inode.c */
  94. struct super_block *smb_read_super(struct super_block *, void *, int);
  95. void smb_get_inode_attr(struct inode *, struct smb_fattr *);
  96. void smb_invalidate_inodes(struct smb_sb_info *);
  97. int  smb_revalidate_inode(struct dentry *);
  98. int  smb_notify_change(struct dentry *, struct iattr *);
  99. unsigned long smb_invent_inos(unsigned long);
  100. struct inode *smb_iget(struct super_block *, struct smb_fattr *);
  101. extern int init_smb_fs(void);
  102.  
  103. /* linux/fs/smbfs/proc.c */
  104. __u32 smb_len(unsigned char *);
  105. __u8 *smb_encode_smb_length(__u8 *, __u32);
  106. __u8 *smb_setup_header(struct smb_sb_info *, __u8, __u16, __u16);
  107. int smb_get_rsize(struct smb_sb_info *);
  108. int smb_get_wsize(struct smb_sb_info *);
  109. int smb_newconn(struct smb_sb_info *, struct smb_conn_opt *);
  110. int smb_errno(struct smb_sb_info *);
  111. int smb_close(struct inode *);
  112. void smb_close_dentry(struct dentry *);
  113. int smb_close_fileid(struct dentry *, __u16);
  114. int smb_open(struct dentry *, int);
  115. int smb_proc_read(struct dentry *, off_t, int, char *);
  116. int smb_proc_write(struct dentry *, off_t, int, const char *);
  117. int smb_proc_create(struct dentry *, __u16, time_t, __u16 *);
  118. int smb_proc_mv(struct dentry *, struct dentry *);
  119. int smb_proc_mkdir(struct dentry *);
  120. int smb_proc_rmdir(struct dentry *);
  121. int smb_proc_unlink(struct dentry *);
  122. int smb_proc_readdir(struct dentry *, int, void *);
  123. int smb_proc_getattr(struct dentry *, struct smb_fattr *);
  124. int smb_proc_setattr(struct dentry *, struct smb_fattr *);
  125. int smb_proc_settime(struct dentry *, struct smb_fattr *);
  126. int smb_proc_dskattr(struct super_block *, struct statfs *);
  127. int smb_proc_reconnect(struct smb_sb_info *);
  128. int smb_proc_connect(struct smb_sb_info *);
  129. int smb_proc_disconnect(struct smb_sb_info *);
  130. int smb_proc_trunc(struct smb_sb_info *, __u16, __u32);
  131. void smb_init_root_dirent(struct smb_sb_info *, struct smb_fattr *);
  132.  
  133. static inline int
  134. smb_is_open(struct inode *i)
  135. {
  136.     return (i->u.smbfs_i.open == SMB_SERVER(i)->generation);
  137. }
  138.  
  139. /* linux/fs/smbfs/sock.c */
  140. int smb_round_length(int);
  141. int smb_valid_socket(struct inode *);
  142. void smb_close_socket(struct smb_sb_info *);
  143. int smb_release(struct smb_sb_info *server);
  144. int smb_connect(struct smb_sb_info *server);
  145. int smb_request(struct smb_sb_info *server);
  146. int smb_request_read_raw(struct smb_sb_info *, unsigned char *, int);
  147. int smb_request_write_raw(struct smb_sb_info *, unsigned const char *, int);
  148. int smb_catch_keepalive(struct smb_sb_info *server);
  149. int smb_dont_catch_keepalive(struct smb_sb_info *server);
  150. int smb_trans2_request(struct smb_sb_info *server, __u16 trans2_command,
  151.                int ldata, unsigned char *data,
  152.                int lparam, unsigned char *param,
  153.                int *lrdata, unsigned char **rdata,
  154.                int *lrparam, unsigned char **rparam);
  155.  
  156. /* fs/smbfs/cache.c */
  157.  
  158. /*
  159.  * The cache index describes the pages mapped starting
  160.  * at offset PAGE_SIZE.  We keep only a minimal amount
  161.  * of information here.
  162.  */
  163. struct cache_index {
  164.     unsigned short num_entries;
  165.     unsigned short space;
  166.     struct cache_block * block;
  167. };
  168.  
  169. #define NINDEX (PAGE_SIZE-64)/sizeof(struct cache_index)
  170. /*
  171.  * The cache head is mapped as the page at offset 0.
  172.  */
  173. struct cache_head {
  174.     int    valid;
  175.     int    status;        /* error code or 0 */
  176.     int    entries;    /* total entries */
  177.     int    pages;        /* number of data pages */
  178.     int    idx;        /* index of current data page */
  179.     struct cache_index index[NINDEX];
  180. };
  181.  
  182. /*
  183.  * An array of cache_entry structures holds information
  184.  * for each object in the cache_block.
  185.  */
  186. struct cache_entry {
  187.     ino_t ino;
  188.     unsigned short namelen;
  189.     unsigned short offset;
  190. };
  191.  
  192. /*
  193.  * The cache blocks hold the actual data.  The entry table grows up
  194.  * while the names grow down, and we have space until they meet.
  195.  */
  196. struct cache_block {
  197.     union {
  198.         struct cache_entry table[1];
  199.         char    names[PAGE_SIZE];
  200.     } cb_data;
  201. };
  202.  
  203. /*
  204.  * To return an entry, we can pass a reference to the
  205.  * name instead of having to copy it.
  206.  */
  207. struct cache_dirent {
  208.     ino_t ino;
  209.     unsigned long pos;
  210.     int len;
  211.     char * name;
  212. };
  213.  
  214. struct cache_head * smb_get_dircache(struct dentry *);
  215. void smb_init_dircache(struct cache_head *);
  216. void smb_free_dircache(struct cache_head *);
  217. int  smb_refill_dircache(struct cache_head *, struct dentry *);
  218. void smb_add_to_cache(struct cache_head *, struct cache_dirent *, off_t);
  219. int  smb_find_in_cache(struct cache_head *, off_t, struct cache_dirent *);
  220. void smb_invalid_dir_cache(struct inode *);
  221.  
  222. #endif /* __KERNEL__ */
  223.  
  224. #endif /* _LINUX_SMB_FS_H */
  225.